import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

import publicPosts from "../pages/publicPosts.vue";
import privatePosts from "../pages/privatePosts.vue";
import account from "../pages/account.vue";
import personInfo from "../pages/personInfo.vue";
import personPrivacy from "../pages/personPrivacy.vue";
import personConfig from "../pages/personConfig.vue";
import detailsPosts from "../pages/detailsPosts.vue";
import newPost from "../pages/newPost.vue";
import otherInfo from "../pages/otherInfo.vue";

//解决了重复路由报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new VueRouter({
    routes:[
        {
            path:"/",
            redirect:"/publicPosts"
        },
        {
            name:"publicPosts",
            path:"/publicPosts",
            component:publicPosts
        },
        {
            name:"privatePosts",
            path:"/privatePosts",
            component:privatePosts
        },
        {
            name:"account",
            path: "/account",
            component:account
        },
        {
            name:"personInfo",
            path:"/personInfo",
            component:personInfo
        },
        {
            name:"personPrivacy",
            path:"/personPrivacy",
            component:personPrivacy
        },
        {
            name:"personConfig",
            path:"/personConfig",
            component:personConfig
        },
        {
            name:"detailsPosts",
            path:"/detailsPosts",
            component:detailsPosts
        },
        {
            name:"newPost",
            path:"/newPost",
            component:newPost
        },
        {
            name:"otherInfo",
            path:"/otherInfo",
            component:otherInfo
        }
    ]
})